package jmt.engine.NetStrategies.RoutingStrategies;

import jmt.common.exception.IncorrectDistributionParameterException;
import jmt.common.exception.LoadException;
import jmt.engine.random.AbstractParameter;
import jmt.engine.random.Empirical;
import jmt.engine.random.EmpiricalEntry;
import jmt.engine.random.EmpiricalPar;
import jmt.engine.random.Parameter;

public class EnergyAwareRoutingParameter implements Comparable<Object> {
	
	private double popMix;
	private double age;
	private double winSize;
	private double probabilities[];
	private String[] paramNames;
    private Empirical distribution;
	private EmpiricalPar param;
	
	public EnergyAwareRoutingParameter(Integer from, EmpiricalEntry entries[]) throws IncorrectDistributionParameterException {
		probabilities = new double[entries.length];
		paramNames = new String[entries.length];
		
		for(int i=0; i<entries.length; i++) {
			EmpiricalEntry entry = entries[i];
			if (entry.getValue() instanceof String) {
				//gets the value contained in the empirical entry (in this case this
				//object is the name of the output node)
				String paramName = (String) entry.getValue();

				//sets the name of the node; the corresponding NetNode object will be found later
				paramNames[i] = paramName;

				//sets the corresponding routing probability
				probabilities[i] = entry.getProbability();
			}
		}
		for(int i=0; i<probabilities.length; i++) {
			switch (paramNames[i]) {
				case "PopulationMix": this.popMix = probabilities[i];
					break;
				case "Age": this.age = probabilities[i];
					break;
				case "WindowSize": this.winSize = probabilities[i];
					break;
			}		
		}
		distribution = new Empirical();
		//param = new EmpiricalPar(probabilities); commentato altrimenti problemi con assegnazione parametri... così nessun problema
		
    }
	
//	public EnergyAwareRoutingParameter(double mix, double age, double win) {
//		this.setPopMix(mix);
//		this.setAge(age);
//		this.setWinSize(win);
//	}
	
//	public void setPopMix(double val) {
//		this.popMix = val;
//	}
//	
//	public void setAge(double val) {
//		this.age = val;
//	}
//	
//	public void setWinSize(double val) {
//		this.winSize = val;
//	}
	
	public double getPopMix() {
		 return this.popMix;
	}
	
	public double getAge() {
		return this.age;
	}
	
	public double getWinSize() {
		return this.winSize;
	}

	@Override
	public int compareTo(Object o) {
		// TODO Auto-generated method stub
		return 0;
	}
}
